# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgbase="c-ares"
pkgname=("libcares" "libcares-devel")
pkgver=1.10.0
pkgrel=2
pkgdesc="C library that performs DNS requests and name resolves asynchronously (libraries)"
arch=('i686' 'x86_64')
url="http://c-ares.haxx.se/"
license=("MIT")
makedepends=("gcc")
depends=("gcc-libs")
options=('staticlibs')
source=("http://c-ares.haxx.se/download/$pkgbase-$pkgver.tar.gz"{,.asc}
        "http://c-ares.haxx.se/license.html")
sha256sums=('3d701674615d1158e56a59aaede7891f2dde3da0f46a6d3c684e0ae70f52d3db'
            'SKIP'
            'aa259141af2018178b832960800be9eaec1b04b18b54b55748e6735396962597')

prepare() {
  cd "$srcdir/$pkgbase-$pkgver"
  autoreconf -ivf
}

build() {
  cd "$srcdir/$pkgbase-$pkgver"
  ./configure \
    --prefix=/usr \
    --enable-shared \
    --enable-static
  make
  make DESTDIR="$srcdir/dest" install
  install -Dm644 $srcdir/license.html $srcdir/dest/usr/share/licenses/c-ares/license.html
}

check() {
  cd "$srcdir/$pkgbase-$pkgver"
  make -k check
}

package_libcares() {
  groups=('libraries')

  mkdir -p $pkgdir/usr/bin
  cp -rf $srcdir/dest/usr/bin $pkgdir/usr/

  mkdir -p $pkgdir/usr/share
  cp -rf $srcdir/dest/usr/share $pkgdir/usr/
}

package_libcares-devel() {
  pkgdesc="c-ares headers and libraries (development)"
  groups=('development')
  depends=("libcares=${pkgver}")

  mkdir -p $pkgdir/usr
  cp -rf $srcdir/dest/usr/include $pkgdir/usr/
  cp -rf $srcdir/dest/usr/lib $pkgdir/usr/
}
